{extend name="public/base" /}
{block name="title"}
投稿-{$webInfo.webname}
{/block}

{block name="content"}
<div class="layui-card" style="width: 1000px;margin: 0 auto;">
    <div class="layui-card-header">投稿</div>
        <div class="layui-card-body">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 100px;">文章标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" placeholder="请输入文章标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 100px;">文章标签</label>
                    <div class="layui-input-block">
                        <input type="text" name="tags" placeholder="请输入文章标签，以|分割" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 100px;">所属栏目</label>
                    <div class="layui-input-block">
                        <select name="cate_id" lay-verify="required">
                            <option value=""></option>
                            {volist name="cates" id="vo"}
                            <option value="{$vo.id}">{$vo.catename}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 100px;">文章描述</label>
                    <div class="layui-input-block">
                        <input type="text" name="desc" placeholder="请输入文章描述" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label" style="width: 100px;">文章内容</label>
                    <div class="layui-input-block">
                        <textarea id="demo" name="content" style="display: none;"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" class="layui-btn" id="add">提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
</div>
{/block}
{block name="js"}
<script src="__STATIC__/lib/layui/layui.js"></script>
<script>
    layui.use('layedit', function(){
        var layedit = layui.layedit;
        layedit.build('demo'); //建立编辑器
    });

    $(function () {
        //提交操作
        $('#add').click(function () {
            $.ajax({
                url: '{:url("index/contribution/contriadd")}',
                type: 'post',
                data: $('form').serialize(),
                dataType: 'json',
                success: function (data) {
                    if (data.code == 1) {
                        layer.msg(data.msg, {
                            icon: 6,
                            time: 2000
                        }, function () {
                            location.href = data.url;
                        });
                    }else {
                        layer.open({
                            title: '投稿失败',
                            content: data.msg,
                            icon: 5,
                            anim: 6
                        });
                    }
                }
            });
            return false;
        });
    });
</script>
{/block}